
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TrainingsApp.Model;
using TrainingsApp.Helper;
using WisDragon.Framework.Data.DataAccess;

namespace TrainingsApp.DAL
{
    public class TS_School_Position_DAL
    {
        public static TS_School_Position_Collecion TS_School_Position_ListByPaging(int pageSize, int pageIndex)
        {
            TS_School_Position_Collecion list = new TS_School_Position_Collecion();
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("TS_School_Position_ListByPaging");
                cmd.SetParameterValue("@pageSize", pageSize);
                cmd.SetParameterValue("@pageIndex", pageIndex);
                List<TS_School_Position_Entity> pageList = cmd.ExecuteEntityList<TS_School_Position_Entity>();
                list. TS_School_Position_List = pageList;
                list.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@recordCount"));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return list;

        }

        public static TS_School_Position_Entity TS_School_Position_View(System.Int32 Idx)
        {
            TS_School_Position_Entity c = default(TS_School_Position_Entity);
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("TS_School_Position_View");
                cmd.SetParameterValue("@Idx", Idx);
                c = cmd.ExecuteEntity<TS_School_Position_Entity>();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public static TS_School_Position_Entity TS_School_Position_Add(TS_School_Position_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("TS_School_Position_Add");
                cmd.SetParameterValue("@PositionName", entity.PositionName);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public static void TS_School_Position_Update(TS_School_Position_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("TS_School_Position_Update");
                cmd.SetParameterValue("@Idx", entity.Idx);
                cmd.SetParameterValue("@PositionName", entity.PositionName);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
        }

        public static void TS_School_Position_Delete(System.Int32 Idx)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("TS_School_Position_Delete");
                cmd.SetParameterValue("@Idx", Idx);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
        }
    }
}
